package cn.kgm.optional;

import cn.kgm.entity.User;

import java.util.Optional;

/**
 * Create by kappi on
 * 2021/12/10/010 21:01
 */
public class OptionalTes {
    public static void main(String[] args) throws Exception{
        User u = null;
        Optional.ofNullable(u).orElseThrow(()->new Exception("用户信息为空！"));
        Optional.ofNullable(0).filter(i->i>=1).orElseThrow(()->new Exception("更新数据失败！"));
    }
}
